#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
#define ls x<<1
#define rs x<<1|1
#define lson x<<1,l,mid
#define rson x<<1|1,mid+1,r
#define ins(s,x) s.insert(x)
#define clr(s,x) s.erase(s.find(x))
#define ll long long
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
using namespace std;
const int N = 1e6+5,V = 1e6,inf = 1e9;
multiset<int> sl,sr,pl[N],pr[N];
struct node{int x,mxl,mir;}t[N << 2];
void update(int x)
{t[x] = {min({t[ls].x,t[rs].x,t[rs].mir-t[ls].mxl}),max(t[ls].mxl,t[rs].mxl),min(t[ls].mir,t[rs].mir)};}
void modify(int x,int l,int r,int i)
{
    if(l == r)
    {
        t[x].mxl = pl[i].empty()?-inf:*pl[i].rbegin();
        t[x].mir = pr[i].empty()?inf:*pr[i].begin();
        t[x].x = t[x].mir-t[x].mxl;
        return ;
    }
    int mid = l+r>>1;
    i <= mid?modify(lson,i):modify(rson,i);
    update(x);
}
int solve()
{
    int mxl = *sl.rbegin(),mir = *sr.begin();
    return mxl < mir?*pr[mxl].begin()-*pl[mir].rbegin():t[1].x;
}
char buf[1<<21],*p1,*p2;
inline int rd()
{
    char c;int f = 1;
    while(!isdigit(c = getchar()))if(c=='-')f = -1;
    int x = c-'0';
    while(isdigit(c = getchar()))x = x*10+(c^48);
    return x*f;
}
inline char gc()
{char c;while((c = getchar()) <= ' ');return c;}
int main()
{
    freopen("stone.in","r",stdin);
    freopen("stone.out","w",stdout);
    for(int i = 1;i < V*4;i++)t[i] = {inf,-inf,inf};
    for(int q = rd();q--;)
    {
        char op = gc();int l = rd(),r = rd();
        if(op == 'A')ins(sl,l),ins(sr,r),ins(pl[r],l),ins(pr[l],r);
        else clr(sl,l),clr(sr,r),clr(pl[r],l),clr(pr[l],r);
        modify(1,1,V,l);modify(1,1,V,r);
        printf("%d\n",solve());
    }
    return 0;
}